﻿using DBMan.Common.Helper;
using System;
using System.Collections.Generic;
using System.Text;

namespace DBMan.Common.Global
{
    public class GlobalParameters
    {
        public static string NDTest { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public static string MQTTServer { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public static int MQTTPort { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public static string MQTTUserName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public static string MQTTPassWord { get; set; }

        /// <summary>
        /// 是否启用xxx对接
        /// </summary>
        public static bool IsBinJiang { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public static string MQTTClientId { get; set; }

        public static void Init(bool isByJson = false, string strPath = "")
        {
            try
            {
                NDTest = Configs.GetAndAdd("NDTest", "KD123");
                MQTTServer = Configs.GetAndAdd("MQTTServer", "118.178.197.13");
                MQTTPort = 1883;
                try
                {
                    MQTTPort = int.Parse(Configs.GetAndAdd("MQTTPort", "1883"));
                }
                catch { }
                MQTTUserName = Configs.GetAndAdd("MQTTUserName", "A000001_1");
                MQTTPassWord = Configs.GetAndAdd("MQTTPassWord", "BJWY_2019_FSKJ");
                IsBinJiang = (Configs.GetAndAdd("IsBinJiang", "False").Trim().ToLower() == "true");
                MQTTClientId = Configs.GetAndAdd("MQTTClientId", "A000001_1");
            }
            catch (Exception ex)
            {
                LogWrite.TxtExport_DateNow("LogErr.txt", $"GlobalParameters Init Err:{ex.Message}");
            }
        }
    }
}
